#include "Tiger.h"
#include "EcoSystem.h"
#include <iostream>

Tiger::Tiger(EcoSystem *eco_system) :
Consumer(eco_system)
{
    set_alive();
    set_max_hp(1500);
    set_hp(1200);
    set_init_speed(1.0);
    set_speed(1.0);
    set_life_span(LIFE_SPAN[get_species_id()] * (1 + max(min(0.2, EcoSystem::random_double() - 0.5), -0.2)));

}

Tiger::~Tiger() {}

inline const unsigned int Tiger::get_species_id() const
{
    return TIGER_SPECIES_ID;
}

Gdiplus::Image *Tiger::get_entity_image() const
{
    static Gdiplus::Image *img = Gdiplus::Image::FromFile(L".\\images\\Tiger.png");
    return img;
}

Entity *Tiger::new_entity() const
{
    return new Tiger(eco_system);
}

void Tiger::on_tick()
{
    set_age(get_age() + 1);
    natural_growth();
    multiply();
    //std::cout << get_max_hp() << " " << get_init_speed() << std::endl;
    set_hp(get_hp() -  get_speed() * get_speed() / 2);
    
    double factor = get_environment_factor();
    if (hungry() > 0.8 || !prey(1.75*get_init_speed()*factor))
    {
        if (hungry() < 0.72)
            random_motion(1.25*get_init_speed()*factor);
        else
            brownian_motion(get_init_speed()*factor);
    }
    else random_motion(get_init_speed());
}

int    Tiger::get_cost_of_being_preyed() const
{
    return 2000;
}
int    Tiger::get_gain_after_being_preyed() const
{
    return 3000;
}